#include("/front/teacher/_layout.html")
#@layout()
#define layoutImportcss()
#end
#define layoutHead()
	<title>学生主页</title>
#end
#define layoutHome()
#include("inc_toolbar.html")

<div class="page-content patriarch-page-content">
	<div class="navbar">
		<div class="navbar-inner toolbstyle">
			<div class="left">
				<a href="javascript:window.location.href='/front/teacher/html/students'" class="link back">
					<i class="icon icon-back"></i>
				</a>
			</div>
			<div class="title">学生主页</div>
			<div class="right"></div>
		</div>
	</div>
	
	<div class="user-head-screen1">
	    <span class="head-portrait head-portrait-big" style="background:url(/front/img/indexbg1.jpg) no-repeat left top #ffffff;"><img id="user_head_img" src="/front/img/user.png"></span>
		<span class="head-username" id="student_name_span"></span>
	</div>
	<div class="list">
		<ul>
			<li>
				<a class="item-link external" href="/front/teacher/html/stuinfo">
					<div class="item-content">
						<div class="item-inner">
							<div class="item-title">学生信息</div>
							<div class="item-value"></div>
						</div>
					</div>
				</a>
			</li>
			<li>
				<a class="item-link external" href="/front/teacher/html/stuparents">
					<div class="item-content">
						<div class="item-inner">
							<div class="item-title">家长信息</div>
							<div class="item-value"></div>
						</div>
					</div>
				</a>
			</li>
			<li>
				<a class="item-link external" href="/front/teacher/html/attendance">
					<div class="item-content">
						<div class="item-inner">
							<div class="item-title">出勤记录</div>
							<div class="item-value"></div>
						</div>
					</div>
				</a>
			</li>
			<li>
				<a class="item-link popup-open" data-popup=".popup-roll-call" href="#">
					<div class="item-content">
						<div class="item-inner">
							<div class="item-title">出勤设置</div>
							<div class="item-value" id="roll_call_lab"></div>
						</div>
					</div>
				</a>
			</li>
			<li>
				<a id="a_btn_del" class="item-link" href="#">
					<div class="item-content">
						<div class="item-inner">
							<div class="item-title">删除学生</div>
							<div class="item-value"></div>
						</div>
					</div>
				</a>
			</li>
		</ul>
	</div>
</div>

<div class="popup popup-roll-call">
    <div class="block">
		<div class="row">
			<div class="col-33">
				<a class="link popup-close" href="#">取消</a>
			</div>
			<div class="col-33" style="text-align: center;" id="popup_title">出勤设置</div>
			<div class="col-33" style="text-align: right;">
				<a id="popup_btn_ok" href="#">确定</a>
			</div>
		</div>
    </div>
	<div class="block block-strong">
		<p>
			<label class="radio">
				<input type="radio" name="roll_call" value="1"><i class="icon-radio"></i>
			</label>&nbsp;&nbsp;&nbsp;&nbsp;参与考勤 
		</p>
		<p>
			<label class="radio">
				<input type="radio" name="roll_call" value="0"><i class="icon-radio"></i>
			</label>&nbsp;&nbsp;&nbsp;&nbsp;不参与考勤
		</p>
	</div>
</div>

#end
#define layoutImportjs()
#end
#define layoutScript()
<script type="text/javascript">
	var stu_id = getUrlParam('stuid');
	sendPost('/front/teacher/students/getStudent?stuid='+stu_id, null, function(res){
		//console.log(res);
		if (res.code == 200){
			$$('#user_head_img').attr('src', formatUserHeadImage(res.studata.student_headpic));
			$$('#student_name_span').text(res.studata.student_name);
			$$('#roll_call_lab').text(res.studata.roll_call==1?"参与考勤":"不参与考勤");
		}
	});
	
	var aels = $$('div.list a.item-link');
	for(var i=0; i<aels.length; i++){
		var ael = aels[i];
		$$(ael).attr('href', $$(ael).attr('href')+'?stuid='+stu_id);
	}
	
	$$('#a_btn_del').on('click', function(){
		app.dialog.confirm('确定要删除此学生！','提示', function(){
			sendPost('/front/teacher/students/delStudent?stuid='+stu_id, null, function(res){
				//console.log(res);
				alert(res.msg);
				if (res.code == 200){
					window.location.href="/front/teacher/html/students";
				}
			});
		});
	});
	
	$$('#popup_btn_ok').on('click', function(){
		var rcv = $$('input[name="roll_call"]:checked').val();
		sendPost('/front/teacher/students/update_rollcall', {student_id: stu_id, roll_call: rcv}, function(res){
			//console.log(res);
			if (res.code == 200){
				app.popup.close($$('div.popup-roll-call'));
				$$('#roll_call_lab').text(rcv==1?"参与考勤":"不参与考勤");
			}else{
				app.dialog.alert(res.msg, '提示');
			}
		});
	});
	
</script>
#end